<div class="form">

<?php
        $form = $this->beginWidget('CActiveForm', array(
            'id' => 'game-form',
            'enableAjaxValidation' => true,
            'htmlOptions' => array(
                'enctype' => 'multipart/form-data',
            )
            ));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo CHtml::errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>80,'maxlength'=>128)); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>
        
        <div class="row">
		<?php echo $form->labelEx($model,'code_identifier'); ?>
                <?php echo $form->textField($model,'code_identifier',array('size'=>80,'maxlength'=>128)); ?>
		<?php echo $form->error($model,'code_identifier'); ?>
	</div>
        
        <div class="row">
            <?php echo CHtml::label('Ảnh đại diện:', 'image') ?>
            <br>
            <?php echo CHtml::fileField('image'); ?>
            <br>
        </div> 
        
        <div class="row">
		<?php echo $form->labelEx($model,'alt'); ?>
                <?php echo CHtml::activeTextArea($model,'alt',array('rows'=>10, 'cols'=>70)); ?>		
		<?php echo $form->error($model,'alt'); ?>
	</div>
        
        <div class="row">
		<?php echo $form->labelEx($model,'sapo'); ?>
                <?php echo CHtml::activeTextArea($model,'sapo',array('rows'=>10, 'cols'=>70)); ?>		
		<?php echo $form->error($model,'sapo'); ?>
	</div>
        
        <div class="row">
		<?php echo $form->labelEx($model,'slug'); ?>
                <?php echo $form->textField($model,'slug',array('size'=>80,'maxlength'=>128)); ?>		
		<?php echo $form->error($model,'slug'); ?>
	</div>
        
        <div class="row">
		<?php echo $form->labelEx($model,'meta_title'); ?>
		<?php echo $form->textField($model,'meta_title',array('size'=>80,'maxlength'=>128)); ?>
		<?php echo $form->error($model,'meta_title'); ?>
	</div>
        
        <div class="row">
		<?php echo $form->labelEx($model,'meta_keyword'); ?>
                <?php echo CHtml::activeTextArea($model,'meta_keyword',array('rows'=>10, 'cols'=>70)); ?>		
		<?php echo $form->error($model,'meta_keyword'); ?>
	</div>                       
        
        <div class="row">
		<?php echo $form->labelEx($model,'meta_description'); ?>
                <?php echo CHtml::activeTextArea($model,'meta_description',array('rows'=>10, 'cols'=>70)); ?>		
		<?php echo $form->error($model,'meta_description'); ?>
	</div> 
        
        <div class="row">
		<?php echo $form->labelEx($model,'tags'); ?>
                <?php echo CHtml::activeTextArea($model,'tags',array('rows'=>10, 'cols'=>70)); ?>		
		<?php echo $form->error($model,'tags'); ?>
	</div> 

	<div class="row">
		<?php echo $form->labelEx($model,'description'); ?>
                <?php echo CHtml::activeTextArea($model,'description',array('rows'=>10, 'cols'=>70)); ?>		
		<?php echo $form->error($model,'description'); ?>
	</div>
        
        <div class="row">
		<label>Chi tiết cho j2me: </label>
                <?php echo CHtml::activeTextArea($model,'description_j2me',array('rows'=>10, 'cols'=>70)); ?>		
		<?php echo $form->error($model,'description_j2me'); ?>
	</div>  
                
        <div class="row">
		<?php echo CHtml::label('Nền tảng:', 'platform') ?><br>
                <?php $platform = Platform::model()->findAll(); ?>
                <?php if(isset($platform)):?>
                <?php $arr_platform = array();
                        $arr_link = array();
                ?>
                <?php if(isset($model->id)):?>
                <?php $platformGame = GamePlatform::model()->findAll('game_id = '.$model->id);?>
                    <?php if(isset($platformGame)):?>
                        <?php foreach($platformGame as $value):?>
                            <?php array_push($arr_platform, $value->platform_id); 
                                $arr_link[$value->platform->code_identifier] = $value->market_url;
                            ?>
                        <?php endforeach;?>
                    <?php endif;?>
                <?php endif;?>
                <?php foreach($platform as $item):?>
                    <div class="platform-group">
                        <input type="checkbox" value="<?php echo $item->id ?>" <?php if(in_array($item->id, $arr_platform)) echo "checked='true'" ?> name="platform[]">&nbsp;<label><?php echo $item->name; ?></label>
                        <input type="text" placeholder="Link market" name="<?php echo $item->code_identifier ?>" value="<?php if(isset($arr_link[$item->code_identifier])) echo $arr_link[$item->code_identifier] ?>" style="width:400px">
                    </div>
                <?php endforeach;?>
                <?php endif;?>
		
	</div> 
        
        <div class="row">
            <?php
            $dropDownValue = '';
            $category = GameCategory::model()->findAll();            
            if (isset($model))
                $dropDownValue = $model->category_id;
            ?>
            <?php echo CHtml::label('Thể loại:', 'category') ?><br>
            <?php echo CHtml::dropDownList('category_id', $dropDownValue, CHtml::listData($category, 'id', 'name')); ?>
        </div>
        
        <div class="row">
		<?php echo $form->labelEx($model,'hot'); ?>
		<?php echo $form->dropDownList($model,'hot',array('1'=>'Có','0'=>'Không')); ?>
		<?php echo $form->error($model,'hot'); ?>
	</div>
        
        <div class="row">
		<?php echo $form->labelEx($model,'status'); ?>
		<?php echo $form->dropDownList($model,'status',array('1'=>'Hiện thị','0'=>'Ẩn')); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>                
        
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>
        
<?php $this->endWidget(); ?>

</div><!-- form -->

<script>              
    tinymce.init({
        selector: "textarea#Game_description",
        theme: "modern",
        width: 900,
        height: 1000,       
        plugins: [
             "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
             "insertdatetime save table contextmenu directionality emoticons template paste textcolor filemanager"
       ],                  
       toolbar: "insertfile undo redo | styleselect | bold italic | fontselect |  fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", 
       theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px",
       font_size_style_values: "12px,13px,14px,16px,18px,20px",  
       extended_valid_elements : 'iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],style,script',
       theme_advanced_fonts : "Andale Mono=andale mono,times;"+
                "Arial=arial,helvetica,sans-serif;"+
                "Arial Black=arial black,avant garde;"+
                "Book Antiqua=book antiqua,palatino;"+
                "Comic Sans MS=comic sans ms,sans-serif;"+
                "Courier New=courier new,courier;"+
                "Georgia=georgia,palatino;"+
                "Helvetica=helvetica;"+
                "Impact=impact,chicago;"+
                "Symbol=symbol;"+
                "Tahoma=tahoma,arial,helvetica,sans-serif;"+
                "Terminal=terminal,monaco;"+
                "Times New Roman=times new roman,times;"+
                "Trebuchet MS=trebuchet ms,geneva;"+
                "Verdana=verdana,geneva;"+
                "Webdings=webdings;"+
                "Wingdings=wingdings,zapf dingbats",
       style_formats: [            
            {title: "Headers", items: [
            {title: "Header 1", format: "h1"},
            {title: "Header 2", format: "h2"},
            {title: "Header 3", format: "h3"},
            {title: "Header 4", format: "h4"},
            {title: "Header 5", format: "h5"},
            {title: "Header 6", format: "h6"}
            ]},
            {title: 'Bold text', inline: 'b'},
            {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
            {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
            {title: 'Example 1', inline: 'span', classes: 'example1'},
            {title: 'Example 2', inline: 'span', classes: 'example2'},
            {title: 'Table styles'},
            {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
        ],                
        subfolder:"games"
     });
     
     tinymce.init({
        selector: "textarea#Game_description_j2me",
        theme: "modern",
        width: 900,
        height: 1000,       
        plugins: [
             "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
             "insertdatetime save table contextmenu directionality emoticons template paste textcolor filemanager"
       ],                  
       toolbar: "insertfile undo redo | styleselect | bold italic | fontselect |  fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", 
       theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px",
       font_size_style_values: "12px,13px,14px,16px,18px,20px",  
       extended_valid_elements : 'iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],style,script',
       theme_advanced_fonts : "Andale Mono=andale mono,times;"+
                "Arial=arial,helvetica,sans-serif;"+
                "Arial Black=arial black,avant garde;"+
                "Book Antiqua=book antiqua,palatino;"+
                "Comic Sans MS=comic sans ms,sans-serif;"+
                "Courier New=courier new,courier;"+
                "Georgia=georgia,palatino;"+
                "Helvetica=helvetica;"+
                "Impact=impact,chicago;"+
                "Symbol=symbol;"+
                "Tahoma=tahoma,arial,helvetica,sans-serif;"+
                "Terminal=terminal,monaco;"+
                "Times New Roman=times new roman,times;"+
                "Trebuchet MS=trebuchet ms,geneva;"+
                "Verdana=verdana,geneva;"+
                "Webdings=webdings;"+
                "Wingdings=wingdings,zapf dingbats",
       style_formats: [            
            {title: "Headers", items: [
            {title: "Header 1", format: "h1"},
            {title: "Header 2", format: "h2"},
            {title: "Header 3", format: "h3"},
            {title: "Header 4", format: "h4"},
            {title: "Header 5", format: "h5"},
            {title: "Header 6", format: "h6"}
            ]},
            {title: 'Bold text', inline: 'b'},
            {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
            {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
            {title: 'Example 1', inline: 'span', classes: 'example1'},
            {title: 'Example 2', inline: 'span', classes: 'example2'},
            {title: 'Table styles'},
            {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
        ],                
        subfolder:"games"
     });
     
     tinymce.init({
        selector: "textarea#Game_meta_keyword",
        theme: "modern",
        width: 900,
        height: 200,       
        plugins: [
             "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
             "insertdatetime save table contextmenu directionality emoticons template paste textcolor filemanager"
       ],                  
       toolbar: "insertfile undo redo | styleselect | bold italic | fontselect |  fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", 
       theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px",
       font_size_style_values: "12px,13px,14px,16px,18px,20px",  
       extended_valid_elements : 'iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],style,script',
       theme_advanced_fonts : "Andale Mono=andale mono,times;"+
                "Arial=arial,helvetica,sans-serif;"+
                "Arial Black=arial black,avant garde;"+
                "Book Antiqua=book antiqua,palatino;"+
                "Comic Sans MS=comic sans ms,sans-serif;"+
                "Courier New=courier new,courier;"+
                "Georgia=georgia,palatino;"+
                "Helvetica=helvetica;"+
                "Impact=impact,chicago;"+
                "Symbol=symbol;"+
                "Tahoma=tahoma,arial,helvetica,sans-serif;"+
                "Terminal=terminal,monaco;"+
                "Times New Roman=times new roman,times;"+
                "Trebuchet MS=trebuchet ms,geneva;"+
                "Verdana=verdana,geneva;"+
                "Webdings=webdings;"+
                "Wingdings=wingdings,zapf dingbats",
       style_formats: [
            {title: "Headers", items: [
            {title: "Header 1", format: "h1"},
            {title: "Header 2", format: "h2"},
            {title: "Header 3", format: "h3"},
            {title: "Header 4", format: "h4"},
            {title: "Header 5", format: "h5"},
            {title: "Header 6", format: "h6"}
            ]},
            {title: 'Bold text', inline: 'b'},
            {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
            {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
            {title: 'Example 1', inline: 'span', classes: 'example1'},
            {title: 'Example 2', inline: 'span', classes: 'example2'},
            {title: 'Table styles'},
            {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
        ],        
        subfolder:"games"
     });
     
     tinymce.init({
        selector: "input#Game_meta_title",
        theme: "modern",
        width: 900,
        height: 200,       
        plugins: [
             "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
             "insertdatetime save table contextmenu directionality emoticons template paste textcolor filemanager"
       ],                  
       toolbar: "insertfile undo redo | styleselect | bold italic | fontselect |  fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", 
       theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px",
       font_size_style_values: "12px,13px,14px,16px,18px,20px",  
       extended_valid_elements : 'iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],style,script',
       theme_advanced_fonts : "Andale Mono=andale mono,times;"+
                "Arial=arial,helvetica,sans-serif;"+
                "Arial Black=arial black,avant garde;"+
                "Book Antiqua=book antiqua,palatino;"+
                "Comic Sans MS=comic sans ms,sans-serif;"+
                "Courier New=courier new,courier;"+
                "Georgia=georgia,palatino;"+
                "Helvetica=helvetica;"+
                "Impact=impact,chicago;"+
                "Symbol=symbol;"+
                "Tahoma=tahoma,arial,helvetica,sans-serif;"+
                "Terminal=terminal,monaco;"+
                "Times New Roman=times new roman,times;"+
                "Trebuchet MS=trebuchet ms,geneva;"+
                "Verdana=verdana,geneva;"+
                "Webdings=webdings;"+
                "Wingdings=wingdings,zapf dingbats",
       style_formats: [
           {title: "Headers", items: [
            {title: "Header 1", format: "h1"},
            {title: "Header 2", format: "h2"},
            {title: "Header 3", format: "h3"},
            {title: "Header 4", format: "h4"},
            {title: "Header 5", format: "h5"},
            {title: "Header 6", format: "h6"}
            ]},
            {title: 'Bold text', inline: 'b'},
            {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
            {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
            {title: 'Example 1', inline: 'span', classes: 'example1'},
            {title: 'Example 2', inline: 'span', classes: 'example2'},
            {title: 'Table styles'},
            {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
        ],        
        subfolder:"games"
     });
     
     tinymce.init({
        selector: "textarea#Game_meta_description",
        theme: "modern",
        width: 900,
        height: 200,       
        plugins: [
             "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
             "insertdatetime save table contextmenu directionality emoticons template paste textcolor filemanager"
       ],                  
       toolbar: "insertfile undo redo | styleselect | bold italic | fontselect |  fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", 
       theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px",
       font_size_style_values: "12px,13px,14px,16px,18px,20px",  
       extended_valid_elements : 'iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],style,script',
       theme_advanced_fonts : "Andale Mono=andale mono,times;"+
                "Arial=arial,helvetica,sans-serif;"+
                "Arial Black=arial black,avant garde;"+
                "Book Antiqua=book antiqua,palatino;"+
                "Comic Sans MS=comic sans ms,sans-serif;"+
                "Courier New=courier new,courier;"+
                "Georgia=georgia,palatino;"+
                "Helvetica=helvetica;"+
                "Impact=impact,chicago;"+
                "Symbol=symbol;"+
                "Tahoma=tahoma,arial,helvetica,sans-serif;"+
                "Terminal=terminal,monaco;"+
                "Times New Roman=times new roman,times;"+
                "Trebuchet MS=trebuchet ms,geneva;"+
                "Verdana=verdana,geneva;"+
                "Webdings=webdings;"+
                "Wingdings=wingdings,zapf dingbats",
       style_formats: [
           {title: "Headers", items: [
            {title: "Header 1", format: "h1"},
            {title: "Header 2", format: "h2"},
            {title: "Header 3", format: "h3"},
            {title: "Header 4", format: "h4"},
            {title: "Header 5", format: "h5"},
            {title: "Header 6", format: "h6"}
            ]},
            {title: 'Bold text', inline: 'b'},
            {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
            {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
            {title: 'Example 1', inline: 'span', classes: 'example1'},
            {title: 'Example 2', inline: 'span', classes: 'example2'},
            {title: 'Table styles'},
            {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
        ],        
        subfolder:"games"
     });
     
     tinymce.init({
        selector: "textarea#Game_tags",
        theme: "modern",
        width: 900,
        height: 200,       
        plugins: [
             "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
             "insertdatetime save table contextmenu directionality emoticons template paste textcolor filemanager"
       ],                  
       toolbar: "insertfile undo redo | styleselect | bold italic | fontselect |  fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", 
       theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px",
       font_size_style_values: "12px,13px,14px,16px,18px,20px",  
       extended_valid_elements : 'iframe[src|style|width|height|scrolling|marginwidth|marginheight|frameborder],style,script',
       theme_advanced_fonts : "Andale Mono=andale mono,times;"+
                "Arial=arial,helvetica,sans-serif;"+
                "Arial Black=arial black,avant garde;"+
                "Book Antiqua=book antiqua,palatino;"+
                "Comic Sans MS=comic sans ms,sans-serif;"+
                "Courier New=courier new,courier;"+
                "Georgia=georgia,palatino;"+
                "Helvetica=helvetica;"+
                "Impact=impact,chicago;"+
                "Symbol=symbol;"+
                "Tahoma=tahoma,arial,helvetica,sans-serif;"+
                "Terminal=terminal,monaco;"+
                "Times New Roman=times new roman,times;"+
                "Trebuchet MS=trebuchet ms,geneva;"+
                "Verdana=verdana,geneva;"+
                "Webdings=webdings;"+
                "Wingdings=wingdings,zapf dingbats",
       style_formats: [
           {title: "Headers", items: [
            {title: "Header 1", format: "h1"},
            {title: "Header 2", format: "h2"},
            {title: "Header 3", format: "h3"},
            {title: "Header 4", format: "h4"},
            {title: "Header 5", format: "h5"},
            {title: "Header 6", format: "h6"}
            ]},
            {title: 'Bold text', inline: 'b'},
            {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
            {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
            {title: 'Example 1', inline: 'span', classes: 'example1'},
            {title: 'Example 2', inline: 'span', classes: 'example2'},
            {title: 'Table styles'},
            {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
        ],        
        subfolder:"games"
     });

</script>
